﻿using System;
using System.Collections.Generic;
using DataTransferObject;
using System.Text;

namespace Engine.ScheduleAlgo
{
    public class TaskForSchedule
    {
        #region Attributes
        private Task _task;
        private Boolean _completed;
        private double _weight;
        private double _mappedDuedate;
        private double _mappedStartOnOrAfterDate;
        private double _mappedReleaseDate;
        private List<TaskForSchedule> _predecessorsTasksForSchedule;
        private List<int> _predecessorIDs;
        private int _remainTime;
        private Boolean _unsatisfiedMinimumTimeSplit = false;
        #endregion

        
        #region Properties
        public Task GetTask
        {
            get { return this._task; }
        }

        public int TaskID
        {
            get { return _task.TaskID; }
            
        }

        public String ProjectName
        {
            get { return _task.ProjectName; }
        }

        public int ProjectID
        {
            get { return _task.ProjectID; }
        }

        public int WorkingHourID
        {
            get { return _task.WorkingHourID; }
        }

        public TaskList TaskList
        {
            get { return _task.TaskList; }
        }

        public List<int> PredecessorIDs
        {
            get { return _task.PredecessorIDs; }
           
        }

        public List<TaskForSchedule> TaskPredecessors
        {
            get
            {
                return this._predecessorsTasksForSchedule;
            }
            set
            {
                this._predecessorsTasksForSchedule = value;
            }

        }

        public Double Weight
        {
            get { return _weight; }
            set { _weight = value; }
        }

        /// <summary>
        /// Thiết lập và lấy thông tin về Start Date của task. Nếu Start Date là DateTime.MinValue nghĩa là Task chưa được schedule
        /// </summary>
        /// <value>The start date.</value>
        public DateTime ScheduledStartDate
        {
            get { return _task.ScheduledStartDate; }
            set { _task.ScheduledStartDate = value; }
        }

        public DateTime ScheduledEndDate
        {
            get { return _task.ScheduledEndDate; }
            set { _task.ScheduledEndDate = value; }
        }

        public int Priority
        {
            get { return _task.Priority; }
        }

        public int TotalWork
        {
            get { return _task.TotalWork; }
        }

        public bool Completed
        {
            get { return _completed; }
            set { _completed = value; }
        }

        public String Name
        {
            get { return _task.Name; }
        }

        public int TaskStatusIndex
        {
            get { return _task.TaskStatusIndex; }
        }

        public int TaskPercentageCompletedIndex
        {
            get { return _task.TaskPercentageCompletedIndex; }
        }

        public int MinimumTimeSplit
        {
            get { return _task.MinimumTimeSplit; }
        }

        public Boolean UnSatisfiedMinimumTimeSplit
        {
            get { return _unsatisfiedMinimumTimeSplit; }
            set { _unsatisfiedMinimumTimeSplit = value; }
        }

        public int RemainTime
        {
            get { return _remainTime; }
            set { _remainTime = value; }
        }

        public DateTime DueDate
        {
            get { return _task.DueDate; }
        }

        public DateTime StartOnOrAfterDate
        {
            get { return _task.StartOnOrAfter; }
        }

        public DateTime ReleaseDate
        {
            get { return _task.ReleaseDate; }
        }

        public double MappedReleaseDate
        {
            get { return _mappedReleaseDate; }
            set { _mappedReleaseDate = value; }
        }

        public double MappedDueDate
        {
            get { return _mappedDuedate; }
            set { _mappedDuedate = value; }
        }

        public double MappedStartOnOrAfterDate
        {
            get { return _mappedStartOnOrAfterDate; }
            set { _mappedStartOnOrAfterDate = value; }
        }
        #endregion

        #region Constructors

        public TaskForSchedule(Task task)
        {
            _remainTime = task.RemainTime;
            _completed = task.Completed;
            TaskPredecessors = new List<TaskForSchedule>();
            this._task = task;
            this._predecessorIDs = task.PredecessorIDs;
        }

        #endregion
    }
}
